<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="icon" href=""><!-- 禁止 favicon.ico 请求 -->
</head>
<body>
<h1>swoole-ws 测试</h1>
<script>
var wsUrl = "ws:47.94.15.84:8812";
    var websocket = new WebSocket(wsUrl);

    // 实例对象onopen属性
    websocket.onopen = function (evt) {
        websocket.send("hello websocket test");
        console.log("conected-swoole-success");
    }

    // 接收到消息
    websocket.onmessage = function (evt) {
        console.log("ws-server-return-data:" + evt.data);
    }

    // 关闭连接
    websocket.onclose = function (evt) {
        console.log("ws-server-close");
    }

    // 出错
    websocket.onerror = function (evt) {
        console.log("error:" + evt.data);
    }

</script>
</body>
</html>